package hhAcademicBowl;

import java.io.File;

import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.filechooser.FileNameExtensionFilter;

public class HHAC {
	
	GameData currentGame = new GameData(this);
	hhacGui2 Grid;
	boolean DoubleJeopardy = false;
	
	private int redScore = 0;
	private int blackScore = 0;
	
	public void addToRed(int value) {
		redScore += value;
	}
	
	public void addToBlack(int value) {
		blackScore += value;
	}
	
	public void subFromRed(int value) {
		redScore -= value;
	}
	
	public void subFromBlack(int value) {
		blackScore -= value;
	}
	
	public int getRedScore() {
		return redScore;
	}

	public int getBlackScore() {
		return blackScore;
	}

	public static void main(String[] args) {
		JFrame fr = new JFrame();
		
		JFileChooser open = new JFileChooser();
		open.setFileFilter(new FileNameExtensionFilter("HHAC file", "hhac"));
		open.showOpenDialog(fr);
		HHAC game = new HHAC(open.getSelectedFile());
	}
	
	public HHAC(File fileLocation) {
		super();
		currentGame.loadFromFile(fileLocation);
		try {
			Grid = new hhacGui2(this);
			Grid.frame.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void qToG() {
		if(Grid.qsAsked == 25 && !DoubleJeopardy){//go to DJ
			DoubleJeopardy = true;
			Grid.frame.dispose();
			Grid = new hhacGui2(this);
			Grid.show(); 
		}
		else if(Grid.qsAsked == 25 && DoubleJeopardy){
			Grid.frame.dispose();
			
			currentGame.finaljeo.initialize();
			currentGame.finaljeo.frame.setVisible(true);
		}
		else{
			Grid.show(); 
		}
		
	}
	
	public void openQ(int cat, int qNum){
		
		if(DoubleJeopardy){
			Grid.qsAsked++;
			if(currentGame.doubleQuestions[cat][qNum].dailyDouble){
				DailyDouble disp = new DailyDouble(currentGame.doubleQuestions[cat][qNum]);
			}
			else{
				currentGame.doubleQuestions[cat][qNum].frame.setVisible(true);
			}
			
			
		}
		else{
			Grid.qsAsked++;
			if(currentGame.normalQuestions[cat][qNum].dailyDouble){
				DailyDouble disp = new DailyDouble(currentGame.normalQuestions[cat][qNum]);
			}
			else{
				currentGame.normalQuestions[cat][qNum].frame.setVisible(true);
			}
			
		}
	}
	
	public void endGame() {
		summaryScreen S = new summaryScreen(redScore, blackScore);
	}
	

}



//TODO write the manual
//TODO make a website for it
